package com.tanhua.admin.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.Analysis;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;


import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@Repository
public interface AnalysisMapper extends BaseMapper<Analysis> {

    @Select("select sum(num_registered) from tb_analysis_by_day")
    Integer queryCumulativeUsers();
    @Select("SELECT num_registered amount,record_date title from tb_analysis_by_day where record_date between #{sd} AND #{ed} ")
    List<Map> selectNewSave(@Param("sd") String sd, @Param("ed") String ed);
    @Select("SELECT num_active amount,record_date title from tb_analysis_by_day where record_date between #{sd} AND #{ed} ")
    List<Map> selectActive(@Param("sd")String start,@Param("ed") String end);
    @Select("SELECT num_retention1d amount,record_date title from tb_analysis_by_day where record_date between #{sd} AND #{ed} ")
    List<Map> selectRemain(@Param("sd")String start,@Param("ed") String end);

    @Select("select sum(num_active) from tb_analysis_by_day where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(record_date)")
    Integer queryNumActive30();

    @Select("select sum(num_active) from tb_analysis_by_day where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(record_date)")
    Integer queryNumActive7();
}